<template>
  <div>
    <div class="search">
      <p class="search-text">人员搜索:</p>
      <el-input placeholder="请输入内容" v-model="input" clearable class="search-input">
      </el-input>
      <el-button type="primary" icon="el-icon-search" class="search-button">查询</el-button>
    </div>
    <el-button type="primary" icon="el-icon-circle-plus-outline" class="renyuan-add" size="medium"
      @click="tankuang('add')">新建</el-button>

    <userAdd v-model="dialogFormVisible" :title="title"></userAdd>

    <el-table :data="tableData" style="width: 100%;" :header-cell-style="headClass">
      <el-table-column label="序号" width="80" type="index">
      </el-table-column>
      <el-table-column label="人员名称" width="240" prop="name">
      </el-table-column>
      <el-table-column label="归属区域" width="260" prop="address">
      </el-table-column>
      <el-table-column label="角色" width="240" prop="data">
      </el-table-column>
      <el-table-column label="联系电话" width="260" prop="data">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="tankuang('edit')">修改</el-button>
          <el-button type="text" @click="chaxun(scope.row.id)" style="color: red;">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="block">
      <el-pagination @size-change="10" @current-change="handleCurrentChange" :current-page="currentPage4"
        layout="total,prev, next" :total="16">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import userAdd from './components/userAdd.vue'
export default {
  name: '',
  components: {
    userAdd
  },
  data() {
    return {
      input: '',

      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }],

      currentPage4: 1,
      dialogFormVisible: false,
      title: ''
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    headClass() {
      return 'background:#f3f6fb;color:#7d6666;font-weight:400;'
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    tankuang(e) {
      if (e == 'add') {
        this.dialogFormVisible = true
        this.title = '新增人员'
      } else {
        this.dialogFormVisible = true
        this.title = '修改人员'
      }
    }
  }
}

</script>
<style lang='scss'  scoped>
.search {
  display: flex;
  margin-top: 20px;

  .search-text {
    line-height: 10px;
    color: gray;
  }

  .search-input {
    width: 200px;
    margin: 0 10px;
  }

  .search-button {
    height: 40px;
    background-color: #5f84ff;
    border: 0;
  }
}

.renyuan-add {
  background-color: #ff8437;
  border: 0;
  margin: 50px 0 10px 0;
}
</style>
